﻿using System;
using ExcelReport;
using ExcelReport.Driver.NPOI;
using ExcelReport.Renderers;
using WordAPptAExcelToHtml.ExportDemo;

namespace WordAPptAExcelToHtml
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
            ReadWord.ReadWordConent();
            Console.ReadLine();
        }

        #region 根据Excel模板导出指定的数据
        //参考链接 https://github.com/hanzhaoxin/ExcelReport
        //根据Excel模板导出指定的数据
        static void ExportExcel()
        {
            var list = StudentLogic.GetList();
            Configurator.Put(".xlsx", new WorkbookLoader());
            var num = 1;
            ExportHelper.ExportToLocal(@"templates\student.xlsx", "out.xlsx",
                //注意 SheetRenderer 中的 sheetName必须和模板中的工作簿的名称一致
                new SheetRenderer("Sheet1",
                    new RepeaterRenderer<StudentInfo>("Roster", list,
                        new ParameterRenderer<StudentInfo>("No", t => num++),
                        new ParameterRenderer<StudentInfo>("Name", t => t.Name),
                        new ParameterRenderer<StudentInfo>("Gender", t => t.Gender ? "男" : "女"),
                        new ParameterRenderer<StudentInfo>("Class", t => t.Class),
                        new ParameterRenderer<StudentInfo>("RecordNo", t => t.RecordNo),
                        new ParameterRenderer<StudentInfo>("Phone", t => t.Phone),
                        new ParameterRenderer<StudentInfo>("Email", t => t.Email)
                    ),
                    new ParameterRenderer("Author", "Cheer")
                )
            );
            Console.WriteLine("finished!");
        }

        #endregion
    }
}
